package cn.itcast.nems.base.web.controller.b;

import cn.itcast.nems.oldems.constant.FinanceCorporationEnum;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 贷款公司
 * </p>
 *
 * @author 陈早庆
 * @since 2023年11月30日
 **/
@RestController("bFinanceCorporationController")
@RequestMapping("/b/finance/corporation")
@RequiredArgsConstructor
public class FinanceCorporationController {

    /**
     * 功能描述: 贷款公司下拉
     *
     * @author 陈早庆
     * @update:[变更日期2023年11月30日][更改人姓名][变更描述]
     * @since 2023年11月30日
     */
    @GetMapping("/list")
    public ResponseEntity<?> listFinanceCorporation() {
        FinanceCorporationEnum[] financeCorporations = FinanceCorporationEnum.values();
        List<Map<String, String>> mapList = new ArrayList<>();
        for (FinanceCorporationEnum financeCorporation : financeCorporations) {
            Map<String, String> map = new HashMap<>();
            map.put("key", financeCorporation.name());
            map.put("value", financeCorporation.getName());
            mapList.add(map);
        }
        return ResponseEntity.ok().body(mapList);
    }
}
